package com.java.security;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.io.IOException;
import java.util.Scanner;

/**
 * @Author ynb
 * @Date 2021/5/20 16:33
 * @Version 1.0
 */
public class Base64 {
    public static void main(String[] args) throws IOException {
//        String  str =" 456145dsffsdfd";
        Scanner input = new Scanner(System.in);
       String str=input.next();

        //加密
        String trim = (new BASE64Encoder()).encodeBuffer(str.getBytes()).trim();
        System.out.println("str:"+trim);

        //解密
        byte[] bytes = (new BASE64Decoder()).decodeBuffer(trim);
        String s = new String(bytes);
        System.out.println("s:"+s.toString());
        System.out.println("明文是否相等:"+str.equals(s));
    }
}
